home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / wink24h / src / cdplay2.c < prev    next >
Text File  |  1994-06-01  |  6KB  |  230 lines

  1. #include    <stdio.h>
  2. #include    <stdlib.h>
  3. #include    <cdrfrb.h>
  4. #include    <snd.h>
  5. #include    "defs.h"
  6.  
  7. extern BOOL Input();
  8. extern void wrtstr();
  9. extern int  Sel_menu();
  10. extern char *SPCSTR;
  11.  
  12. /* --------------------- EUP play 92.03.30 ------------------ */
  13. extern void runeup();                             /* customaized by YAMA */
  14. extern void stopeup();                            /* customaized by YAMA */
  15. /* ---------------------------------------------------------- */
  16.  
  17. /* --------------- RED2 Like   92.01.31 Pumpkin ------------- */
  18. extern void Dsp_vram();
  19. extern UCHAR    vram[];
  20. int cd_m_stat = FALSE;
  21. /* ---------------------------------------------------------- */
  22.  
  23. typedef struct TIMEADRS CDTIME;
  24.  
  25. static short   cd_act=FALSE;
  26. static int     type=0,strt=0,endt=0;
  27. static int     vol=64,sts=0,no=0,acv=0;
  28. static CDTIME  st,ed;
  29. static CDTIME  *track=NULL;
  30. /* ------------------ CD No Stop 91.10.18 Pumpkin ----------- */
  31. int    cd_stop = TRUE;
  32. /* ---------------------------------------------------------- */
  33.  
  34. int     CD_open(void)
  35. {
  36.     int     i;
  37.     CDTIME  disc;
  38.  
  39.     if ( track == NULL && 
  40.         (track = (CDTIME *)malloc(sizeof(CDTIME)*99)) == NULL )
  41.         return 1;
  42.  
  43.     do {
  44.         i = cdr_cdinfo(0,&type,&strt,&endt,track,&disc);
  45.     } while ( i == CDERR7 );
  46.  
  47. /*********************************
  48.     char tmp[80];
  49.     sprintf(tmp,"%d:%d:%d",disc.min,disc.sec,disc.frame);
  50.     wrtstr(tmp,30,1,0x15);
  51. *********************************/
  52.  
  53.     if ( disc.frame-- <= 0 ) {
  54.     disc.frame = 74;
  55.     if ( disc.sec-- <= 0 ) {
  56.         disc.sec = 59;
  57.         if ( disc.min-- <= 0 )
  58.         return 1;
  59.     }
  60.     }
  61.     if ( i == 0 ) {
  62.         track[endt].min = disc.min;
  63.         track[endt].sec = disc.sec;
  64.         track[endt].frame = disc.frame;
  65.     acv = 1;
  66.     }
  67.  
  68.     return i;
  69. }
  70. void    CD_play()
  71. {
  72.     int  i;
  73.     char tmp[80],ttl[40];
  74.  
  75. /* --------------- debug   91.08.28 Pumpkin ---------------- */
  76.     i = CDERR7;
  77.     while (i == CDERR7) {
  78.         i = cdr_mphase(0,&sts,&no,&st,&ed);
  79.     }
  80.     if ( i != 0 ) {
  81.     wrtstr("CDが正常にセットされていません ",30,1,0x12);
  82.         return;
  83.     }
  84. /*********
  85.     if ( cdr_mphase(0,&sts,&no,(char *)&st,(char *)&ed) != 0 ) {
  86.     wrtstr("CDが正常にセットされていません?",30,1,0x12);
  87.         return;
  88.     }
  89. ********
  90. /* ---------------------------------------------------------- */
  91.     if ( sts != 0 )
  92.         cdr_pause(0);
  93.  
  94.     if ( CD_open() != 0 ) {
  95.     wrtstr("CD情報の読み取りに失敗しました",30,1,0x12);
  96.     return;
  97.     }
  98.  
  99.     tmp[0] = '\0'; sprintf(ttl,"曲番(1-%d) ",endt);
  100.     if ( Input(tmp,ttl) != FALSE )
  101.     return;
  102.     if ( (no = atoi(tmp) - 1) < 0 || no >= endt ) no = 0;
  103.  
  104. /* ------------------ SIDEWORK 92.01.31 Pumpkin ----------------- */
  105. /******
  106.     SND_elevol_set(1,vol,vol);
  107. ******/
  108. /* ---------------------------------------------------------- */
  109.     if ( endt > 0 ) {
  110.         for ( i=no ; i < endt && (track[i].min & 0x80) != 0 ; i++ );
  111.         if ( cdr_mtplay(0,&(track[i]),&(track[endt])) != 0 )
  112.         wrtstr("正常に演奏出来ません",30,1,0x12);
  113.     }
  114.     if ( track != NULL )
  115.     free(track);
  116.     track = NULL;
  117.     cd_act = TRUE;
  118. }
  119. void    CD_stop()
  120. {
  121.     cdr_mstop(0);
  122.     if ( track != NULL )
  123.     free(track);
  124.     track = NULL;
  125.     cd_act = FALSE;
  126. }
  127. void    CD_endof()
  128. {
  129. /* ------------------ CD No Stop 91.10.18 Pumpkin ----------- */
  130.     int     i;
  131.  
  132.     i = CDERR7;
  133.     while (i == CDERR7) {
  134.         i = cdr_mphase(0,&sts,&no,&st,&ed);
  135.     }
  136.  
  137.     if ( cd_stop == TRUE && sts != 0)
  138.         cdr_mstop(0);
  139. /*****
  140.     if ( cd_act != FALSE )
  141.         cdr_mstop(0);
  142. *****/
  143. /* ---------------------------------------------------------- */
  144. }
  145. void    CD_vol()
  146. {
  147.     char    tmp[80];
  148.  
  149. /* ------------------ SIDEWORK 92.01.31 Pumpkin ------------- */
  150.     SND_elevol_read(1,&vol,&vol);
  151. /* ---------------------------------------------------------- */
  152.     sprintf(tmp,"%d",vol);
  153.     if ( Input(tmp,"音量(0-127) ") != FALSE )
  154.     return;
  155.     vol = atoi(tmp);
  156.     SND_elevol_set(1,vol,vol);
  157. }
  158. void    CD_menu()
  159. {
  160.     static int  no=ERR;
  161. /* --------------- RED2 Like   92.01.31 Pumpkin ------------- */
  162.      static char  *menu[]={
  163.      "P: CD Play      1. CD演奏する     ",
  164.      "S: CD Stop      2. CD演奏を止める ",
  165.     "",
  166.      "V: Volume       3. 音量を設定する   ",
  167.     "",
  168.      "E: Eup Play     4. EUPファイル演奏開始  ",
  169.      "T: Eup Stop     5. EUPファイル演奏停止  ",
  170.     NULL,
  171.     "1 CD演奏する     ",
  172.     "2 CD演奏を止める ",
  173.     "",
  174.     "3 音量を設定する   ",
  175.     "",
  176.     "4 EUPファイル演奏開始  ",             /* customaized by YAMA */
  177.     "5 EUP演奏停止      ",             /* customaized by YAMA */
  178.     NULL };
  179.      int m=0;
  180. /**********
  181.     static char *menu[]={
  182.     "1 CD演奏する     ",
  183.     "2 CD演奏を止める ",
  184.     "",
  185.     "3 音量を設定する   ",
  186.     NULL };
  187. **********/
  188. /* ---------------------------------------------------------- */
  189.  
  190.     wrtstr(SPCSTR,30,1,0x1F);
  191. /* --------------- RED2 Like   92.01.31 Pumpkin ------------- */
  192.     if (cd_m_stat == TRUE) m = 8;
  193.     switch (Sel_menu(&menu[m],30,2,&no)) {
  194.         case FALSE:
  195.             break;
  196.         case LEFT: 
  197.             if (cd_m_stat == FALSE) {
  198.                             Dsp_vram(vram);
  199.                 Cmds_PF4();
  200.             }
  201.             return;
  202.         case RIGHT:
  203.             if (cd_m_stat == FALSE) {
  204.                             Dsp_vram(vram);
  205.                 Cmds_PF1();
  206.             }
  207.             return;
  208.         default:
  209.             return;
  210.     }
  211. /*****
  212.     if ( Sel_menu(menu,30,2,&no) != FALSE )
  213.     return;
  214. *****/
  215. /* ---------------------------------------------------------- */
  216.  
  217.     if ( no == 0 )
  218.     CD_play();
  219.     else if ( no == 1 )
  220.     CD_stop();
  221.     else if ( no == 2 )
  222.     CD_vol();
  223. /* --------------------- EUP play 92.03.30 ------------------ */
  224.     else if ( no == 3 )               /* customaized by YAMA */
  225.     runeup();
  226.     else if ( no == 4 )               /* customaized by YAMA */
  227.     stopeup();
  228. /* ---------------------------------------------------------- */
  229. }
  230.